package com.scu.phototabuser.ui.login.login;


import android.util.Log;

import com.scu.phototabuser.data.Taskable;
import com.scu.phototabuser.data.source.remote.login.LoginTaskable;
import com.scu.phototabuser.util.ToastUtil;

import static com.scu.phototabuser.util.Predictions.checkNotNull;

/**
 * Created by tianfei on 2017/4/11.
 */

public class SingUpPresenter implements LoginContract.Presenter {



    private LoginContract.SingUpView mView;


    public SingUpPresenter(LoginContract.SingUpView view) {
        this.mView = checkNotNull(view);
        view.setPresenter(this);
    }

    @Override
    public void doSignUp(String email, String MD5pass, final LoginContract.LoginCallback callback) {

        LoginTaskable signUp=new LoginTaskable(email,MD5pass) {
            @Override
            public void onFailed(Integer code, String msg) {

                callback.showFailed(code,msg);
                Log.e("signUp:onFailed",code+":"+msg);
                ToastUtil.makeAppContextToast(msg);

            }

            @Override
            public void onSuccess(Object data) {
                callback.showSuccess();
                //mView.backToLoginView();
            }
        };
        signUp.start(Taskable.TASK_TYPE.SINGUP);

    }

    @Override
    public void saveIsNeedLogin(boolean needDoLogin) {

    }

    @Override
    public void setProgressBarVisibility(boolean visibility) {

    }

    @Override
    public void doLogin(String email, String MD5pass, LoginContract.LoginCallback callback) {
        return;
    }

    @Override
    public void release() {

    }
}
